﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using EmoneyWeiXinEntity;
using EmoneyWeiXinCommon;
namespace EmoneyWeiXinDAL
{
    public class WeixinNewsModelSettingFieldDal
    {
        public static List<WeixinNewsModelSettingEntity> getNewsModelFieldList(int mid,int pindex, int psize, out int total)
        {
            SqlParameter[] parameters = new SqlParameter[] {
                 new SqlParameter("@mid", mid),
                 new SqlParameter("@pindex",pindex),
                 new SqlParameter("@psize", psize),
                 new SqlParameter("@total", 0),
            };
            parameters[3].Direction = ParameterDirection.Output;
            List<WeixinNewsModelSettingEntity> result = SQLHelper.GetProcedureDataByColumnsLst<WeixinNewsModelSettingEntity>(Config.EmoneyWeiXin, "sp_WeixinNewsModelSettingField_Select", parameters);
            total = Convert.ToInt32(parameters[3].Value);
            return result;
        }

        public static int UpdateNewsModelField(WeixinNewsModelSettingEntity obj)
        {
            SqlParameter[] parameters = new SqlParameter[] {
                 new SqlParameter("@id", obj.id),
                 new SqlParameter("@mid", obj.mid),
                 new SqlParameter("@fieldname", obj.fieldname),
                 new SqlParameter("@fieldvalue", obj.fieldvalue),
                 new SqlParameter("@style", obj.style),
                 new SqlParameter("@isvalid", obj.isvalid),
                 new SqlParameter("@remark", obj.remark),
                 new SqlParameter("@creator", obj.creator),
            };
            int result = SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, CommandType.StoredProcedure, "sp_WeixinNewsModelSettingField_Update", parameters);
            return result;
        }

        public static int DeleteNewsFieldModel(int id,int status)
        {
            SqlParameter[] parameters = new SqlParameter[] {  
            new SqlParameter("@id", id),
            new SqlParameter("@status", status)};
            int result = SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, CommandType.StoredProcedure, "sp_WeixinNewsModelSettingField_Delete", parameters);
            return result;
        }
    }
}
